package cn.zhpdmmz.service.impl;

import cn.zhpdmmz.entity.HotelRoom;
import cn.zhpdmmz.mapper.HotelRoomMapper;
import cn.zhpdmmz.service.IHotelRoomService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelRoom)表服务实现类
 *
 * @author ZHP
 * @since 2022-05-25 15:17:13
 */
@Service("hotelRoomService")
public class HotelRoomServiceImpl implements IHotelRoomService {
    @Resource
    private HotelRoomMapper hotelRoomMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param roomId 主键
     * @return 实例对象
     */
    @Override
    public HotelRoom queryById(Integer roomId) {
        return this.hotelRoomMapper.queryById(roomId);
    }

    /**
     * 查询指定行
     *
     * @param hotelRoom 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelRoom> queryAll(HotelRoom hotelRoom) {
        return this.hotelRoomMapper.queryAll(hotelRoom);
    }

    /**
     * 新增数据
     *
     * @param hotelRoom 实例对象
     * @return 实例对象
     */
    @Override
    public HotelRoom insert(HotelRoom hotelRoom) {
        this.hotelRoomMapper.insert(hotelRoom);
        return hotelRoom;
    }

    /**
     * 修改数据
     *
     * @param hotelRoom 实例对象
     * @return 实例对象
     */
    @Override
    public HotelRoom update(HotelRoom hotelRoom) {
        this.hotelRoomMapper.update(hotelRoom);
        return this.queryById(hotelRoom.getRoomId());
    }

    /**
     * 通过主键删除数据
     *
     * @param roomId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer roomId) {
        return this.hotelRoomMapper.deleteById(roomId) > 0;
    }

    @Override
    public List<HotelRoom> queryByType(Integer roomTypeId) {

        return this.hotelRoomMapper.queryRoomByType(roomTypeId);
    }
}
